*TABLE A2
*Childcare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synth`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table A2: Childcare pre-r2: Means in the following output
su rsq
}

clear
use "childcareoutput_long.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table A2: Childcare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table A2: Childcare p-value column: Means in the following output
su p_Fla_*


*Education

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthed`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table A2: Education pre-r2: Means in the following output
su rsq
}

clear
use "educationoutput_long.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table A2: Education Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table A2: Education p-value column: Means in the following output
su p_Fla_*



*Elderlycare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthel`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table A2: Elderlycare pre-r2: Means in the following output
su rsq
}

clear
use "elderlyoutput_long.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table A2: Elderlycare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table A2: Elderlycare p-value column: Means in the following output
su p_Fla_*



*Healthcare

clear
foreach t of numlist 1 2 3 4 5 6 7 8 9 10 {
use synthhe`t'_615.dta, clear
drop _Co_Number _W_Weight
gen pre = 1 if _time<1996
keep if pre==1
gen spe  = (_Y_treated - _Y_synthetic)^2
egen m_y_treted = mean(_Y_treated )
gen sqdmean = (_Y_treated - m_y_treted)^2
egen numerator = sum(spe)
egen denominator = sum(sqdmean)
gen rsq = 1- (numerator/denominator)
*Table A2: Healthcare pre-r2: Means in the following output
su rsq
}

clear
use "healthoutput_long.dta"

foreach t of numlist 1 2 3 4 5 6 7 8 9 10{
sort komnr model
qui su RMSPE if komnr==615 & model==`t'
gen RMSPE_Fla_`t' = r(mean)
egen rank_RMSPE_`t' = rank(-RMSPE) if model==`t'
gen rank_RMSPE_Fla_`t'=rank_RMSPE_`t' if komnr==615 & model==`t'
gen p_Fla_`t' = rank_RMSPE_Fla_`t'/164
}

*Table A2: Healthcare Post MSPE column: Means in the following output
bys model: su postmspe if komnr!=615

*Table A2: Healthcare p-value column: Means in the following output
su p_Fla_*
